package com.xssn.fjnd.system.feign;



import com.xssn.fjnd.entities.SysMenu;
import com.xssn.fjnd.entities.SysUser;
import com.xssn.fjnd.feign.IFeignSystemController;
import com.xssn.fjnd.feign.req.UserInfoREQ;
import com.xssn.fjnd.feign.req.WxUserInfoREQ;
import com.xssn.fjnd.system.service.ISysMenuService;
import com.xssn.fjnd.system.service.ISysUserService;
import com.xssn.util.base.Result;
import com.xssn.util.exception.XssnException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class FeignSystemController implements IFeignSystemController {

    @Autowired
    private ISysUserService sysUserService;

    @Autowired
    private ISysMenuService sysMenuService;

    /**
     * 通过用户名查询用户信息
     * @param username 用户名
     * @return
     */
    @Override
    public SysUser findUserByUsername(String username) {
        return sysUserService.findByUsername(username);
    }

    /**
     *通过用户ID查询拥有权限
     * @param userId 用户id
     * @return
     */
    @Override
    public List<SysMenu> findMenuListByUserId(String userId) {
        return sysMenuService.findByUserId(userId);
    }


    /**
     * 微信新用户注册同时保留sys_user表
     * @param sysUser
     * @return
     */
    public boolean saveUser(SysUser sysUser) {

        return sysUserService.save(sysUser);
    }

    @Override
    public Result updateUserInfo(WxUserInfoREQ wxreq) {
        return sysUserService.updateUserInfo(wxreq);
    }

}
